package cums.db.impl;

import cums.db.iface.PropertiesDao;
import cums.db.pers.Properties;
import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * @time Dec 4, 2009, 2:05:01 PM
 * @author fdcube
 */
public class PropertiesImpl extends HibernateDaoSupport implements PropertiesDao {

    public Properties AddorUpdateProperties(Properties value) {
        this.getHibernateTemplate().saveOrUpdate(value);
        return value;
    }

    public boolean DeleteProperties(Properties value) {
        try {
            this.getHibernateTemplate().delete(value);
            return true;
        } catch (DataAccessException dataAccessException) {
            logger.error(dataAccessException);
            return false;
        }
    }

    public List<Properties> FindPropertiesByPid(int value) {
        return this.getHibernateTemplate().findByNamedParam("FROM PROPERTIES AS p WHERE u.PID =:value", "value", value);
    }

    public List<Properties> ListProperties() {
        return this.getHibernateTemplate().find("FROM PROPERTIES ORDER BY PID");
    }

    public List<Properties> FindPropertiesByPname(String value) {
        return this.getHibernateTemplate().findByNamedParam("FROM PROPERTIES AS p WHERE u.PNAME =:value", "value", value);
    }
}
